package com.tgh.utils;

public class GLGeometryTransform {

    public GLGeometryTransform() {}
    
    public void setMatrixStack(GLMatrixStack modelView,GLMatrixStack projection) {
        this.mModelView=modelView;
        this.mProjection=projection;
    }
    
    public void setModelViewMatrixStack(GLMatrixStack modelView) {
        this.mModelView = modelView;
    }
    
    public void setProjectionMatrixStack(GLMatrixStack projection) {
        this.mProjection = projection;
    }
    
    public Matrix44f getModelViewProjectionMatrix() {
        mModelViewProjection.load(mProjection.getMatrix());
        mModelViewProjection.multiply(mModelView.getMatrix());
        return mModelViewProjection;
    }
    
    public Matrix44f getModelViewMatrix() {
        return mModelView.getMatrix();
    }
    
    public Matrix44f getProjectionMatrix() {
        return mProjection.getMatrix();
    }
    
    public Matrix33f getNormalMatrix(boolean normalize) {
        Matrix33f normalMatrix = getModelViewMatrix().extractRotationMatrix33();
        if (normalize) {
            Vector3f.normalize(normalMatrix.mMat, 0);
            Vector3f.normalize(normalMatrix.mMat, 3);
            Vector3f.normalize(normalMatrix.mMat, 6);
        }
        return normalMatrix;
    }

    private GLMatrixStack mModelView;
    private GLMatrixStack mProjection;
    private Matrix44f mModelViewProjection=new Matrix44f();
}
